package org.java.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;
import tk.mybatis.mapper.annotation.KeySql;

import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.util.Date;

/**
 * @author WHQ
 * @version 1.0
 * @date 2022-2-16 0016 下午 5:32
 */
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "user_info")
public class User implements Serializable {
    @Id
    @KeySql(useGeneratedKeys = true)
    private Long id;
    @Pattern(regexp = "^(\\w+([-.][A-Za-z0-9]+)*){3,18}@\\w+([-.][A-Za-z0-9]+)*\\.\\w+([-.][A-Za-z0-9]+)*$",message = "邮箱格式错误!")
//    @Length(min = 2,max = 8,message = "用户名的长度必须在2-8位之间")
    private String email;
    //转json的时候忽略此字段
    @JsonIgnore
    @Length(min = 2,max = 8,message = "用户名的长度必须在2-8位之间")
    private String password;
//    /**
//     * /正则表达式验证
//     */
//    @Pattern(regexp = "^1[3,5,6,7,8,9]\\d{9}$",message = "电话号码格式错误!")
//    private String phone;
    /**
     * 注册时间
     */
    private Date created;
    /**
     * 用户加密用的盐
     */
    //转json的时候忽略此字段
    @JsonIgnore
    private String salt;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Date getCreated() {
        return created;
    }

    public void setCreated(Date created) {
        this.created = created;
    }

    public String getSalt() {
        return salt;
    }

    public void setSalt(String salt) {
        this.salt = salt;
    }
}
